package cn.accp.sartwar.baseEntity;

//怪物类
public abstract class Monster {
	// 怪物名
	protected String name;
	// 体重值
	protected int weight;

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the weight
	 */
	public int getWeight() {
		return weight;
	}

	/**
	 * @param weight
	 *            the weight to set
	 */
	public void setWeight(int weight) {
		if (weight > 0) {
			this.weight = weight;
		}
	}

	public Monster() {
	}

	public Monster(String name, int weight) {
		this.name = name;
		setWeight(weight);
	}

	public abstract void attack();

	public abstract void run();

	public abstract void jump();

	/**
	 * 判断是否与当前类属性值相等
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Monster) {
			Monster monster = (Monster) obj;
			return monster.weight == this.weight
					&& monster.name.equals(this.name);
		} else {
			return false;
		}
	}

	/**
	 * 重写的toString方法
	 */
	@Override
	public String toString() {
		return "怪物名：" + this.name + "，体重：" + this.weight;
	}
}